# from flask import Flask
#
#
# # 1 创建flask应用对象
# # __name__ 表示当前模块名字 字符串
# # 第一个参数 表示flask以这个模块所在的目录为工程目录，在目录中以默认名static为静态文件目录 ，templates为模板目录
# # static_url_path 指明访问静态文件的请求路径前缀
# app = Flask(__name__, static_url_path='/s', static_folder='static_files')
#
# # 2 编写视图
# @app.route('/')
# def index():
#     """
#     首页视图函数
#     :return:
#     """
#     # 让页面呈现helloworld
#     return 'helloworld'
#
#
# # 3 启动调试服务器
# if __name__ == '__main__':
#     app.run()
# import time
# start_time=time.time()
# for a in range(0,1001):
#     for b in range(0,1001-a):
#         c=1000-a-b
#         if a**2+b**2==c**2:
#             print('a,b,c:%d,%d,%d' % (a, b, c))
#
# end_time=time.time()
#
# print('time:%f'%(end_time-start_time))

#
# def t1():
#    l = []
#    for i in range(1000):
#       l = l + [i]
# def t2():
#    l = []
#    for i in range(1000):
#       l.append(i)
# def t3():
#    l = [i for i in range(1000)]
# def t4():
#    l = list(range(1000))
#
# from timeit import Timer
#
# timer1 = Timer("t1()", "from __main__ import t1")
# print("concat ",timer1.timeit(number=1000), "seconds")
# timer2 = Timer("t2()", "from __main__ import t2")
# print("append ",timer2.timeit(number=1000), "seconds")
# timer3 = Timer("t3()", "from __main__ import t3")
# print("comprehension ",timer3.timeit(number=1000), "seconds")
# timer4 = Timer("t4()", "from __main__ import t4")
# print("list range ",timer4.timeit(number=1000), "seconds")

# class Stack(object):
#     """栈"""
#
#     def __init__(self):
#         self.items = []
#
#     def is_empty(self):
#         """判断是否为空"""
#         return self.items == []
#
#     def push(self, item):
#         """加入元素"""
#         self.items.append(item)
#
#     def pop(self):
#         """弹出元素"""
#         return self.items.pop()
#
#     def peek(self):
#         """返回栈顶元素"""
#         return self.items[len(self.items) - 1]
#
#     def size(self):
#         """返回栈的大小"""
#         return len(self.items)
#
#
# if __name__ == "__main__":
#     stack = Stack()
#     stack.push("hello")
#     stack.push("world")
#     stack.push("itcast")
#     print(stack.size())
#
#     print(stack.peek())
#
#     print(stack.pop())
#
#     print(stack.pop())
#
#     print(stack.pop())
# l= []
# a = {'num':0}
# for i in range(10):
#     a['num'] = i
#     l.append(a)
# print(l)
#
# A=dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
# print(A)
# a=[]
# for i in range(10):
#     a.append(i)
# print(a)
#
# b=[]
# bb={'id':0}
# for i in range(10):
#     bb['id']=i
#     b.append(bb)
# print(b)

# for i in range(10,0,-1):
#     print(i)

# def get_lines():
#     with open('xx..py ,'r'') as f:
#         while True:
#             data=f.readlines(100)
#             if data:
#                 yield data
#             else:
#                 break
# f=get_lines()
# print(next(f))
# print(next(f))
# print(next(f))

# def get_lines():
#     with open('xx.txt') as f:
#         while True:
#             data=f.readlines(100)
#             if data:
#                 yield data
#             else:
#                 break
# g=get_lines()
# print(next(g))
# print(next(g))
# print(next(g))

# def get_lins():
#     with open('xx.txt','r') as f:
#         while True:
#             data=f.readlines(100)
#             if data:
#                 yield data
#             else:
#                 break
# f=get_lins()
# print(next(f))
# print(next(f))
# print(next(f))

# split -l 2 requirements.txt re.txt

# def get_lines():
#     l=[]
#     with open('1.txt','rb') as f:
#         for oneine in f:
#             l.append(oneine)
#     return l
# if __name__ == '__main__':
#     for e in get_lines():
#         print(e)

# def get_lines():
#     l=[]
#     with open('1.txt','rb') as f:
#         while True:
#             data=f.readlines(10000)
#             if data:
#                 yield data
#             else:
#                 break

    # l.append(data)
    # yield l

# def get_lines():
#     i=[]
#     with open('1.txt','rb') as f:
#         data=f.readlines(1000)
#     i.append(data)
#     yield i

# def sirectory(sPath):
#     import os
#     for aa in os.listdir(sPath):
#         aapath=os.path.join(sPath,aa)
#         if os.path.isdir(aapath):
#             sirectory(aapath)
#         else:
#             print(aapath)

# import datetime
# def dayofyear():
#     year=input('年份：')
#     month=input('月份;')
#     day=input('天数;')
#     # date1=datetime.datetime(year=int(year),month=int(month),day=int(day))
#     # data2=datetime.datetime(year=int(year),month=1,day=1)
#     date1=datetime.date(year=int(year),month=int(month),day=int(day))
#     data2=datetime.date(year=int(year),month=1,day=1)
#     return (date1-data2).days+1
# # a=input('请输入')
# # print(a)
# f=dayofyear()
# print(f)

# print(a[1])

# def Bubble_sort(alist):
# # 冒泡
#     # for j in range(len(alist)-1,0,-1):
#     #     for i in range(j):
#     for j in range(len(alist)-1,0,-1):
#         for i in range(j):
#             if alist[i]>alist[i+1]:
#                 alist[i],alist[i+1]=alist[i+1],alist[i]
# def quick_sort(alist):
#     if len(alist)<2:
#         return alist
#     else:
#         num=alist[0]
#         lift1=[x for x in alist if x <=num]
#         right1=[x for x in alist if x>num]
#         return quick_sort(lift1)+[num]+quick_sort([right1])

# def quick_sort(array):
    # for j in range(len(array)-1): #0,1,2,3
    #     for i in range(len(array)-1-j): #n-1 n-2
    # for j in range(len(array)-1,0,-1):  #n-1,n-2
    #     for i in range(j): #
    #         if array[i]>array[i+1]:
    #             array[i],array[i+1]=array[i+1],array[i]
# def quick_sort(alist, start, end):
    # if start>=end:
    #     return
    # mid=alist[start]
    # low=start
    # high=end
    # while low<high:
    #     while low<high and alist[high]>=mid:
    #         high-=1
    #     alist[low]=alist[high]
    #
    #     while low<high and alist[low]<mid:
    #         low+=1
    #     alist[high]=alist[low]
    #
    # alist[low]=mid
    # quick_sort(alist,start,low-1)
    # quick_sort(alist,low+1,end)

    # if start>=end:
    #     return
    # mid=alist[0]
    # lift=[]
    # right=[]
    # alist.remove(mid)
    # for i in range(len(alist)):
    #     a=alist[i]
    #     if a<=mid:
    #         lift.append(a)
    #     else:
    #         right.append(a)
    # return quick_sort(lift,0,len(lift)-1)+[mid]+quick_sort(right,0,len(right)-1)

# a=[2,5,8,1,3,4,9,4,2,7]
# # quick_sort(a)
# quick_sort(a,0,len(a)-1)
# # Bubble_sort(a)
# print(a)

# d={'a':2,'d':1,'b':11,'s':7}
# s=sorted(d.values())
# print(s)
# b=sorted(d.items())
# print(b)
# c=sorted(d.items(),key = lambda x:x[1])
# print(c)
# xx=sorted(d.items(),key=lambda a:a[1])
# print(xx)
# a='123456aabb'
# c=a[::-1]
# d=c[::-1]
# print(c)
# print(d)
str1 = "k:1|k1:2|k2:3|k3:4"
aa=str1.split('|')
# print(aa)
# dict1={}
# for i in aa:
#     key,value=i.split(':')
#     dict1[key]=value
# print(dict1)

# str1 = "k:1|k1:2|k2:3|k3:4"
# def str2dict(str1):
#     dict1 = {}
#     for iterms in str1.split('|'):
#         key,value = iterms.split(':')
#         dict1[key] = value
#     return dict1
# a=str2dict(str1)
# print(a)
# 添加一个登录验证的功能
# str1="k:1|k1:2|k2:3|k3:4"
# dict1={}
# for items in str1.split('|'):
#     key,value=items.split(':')
#     dict1[key]=value
# print(dict1)
# alist=[{'name': 'a','age': 20},{'name': 'b','age': 30},{'name': 'c','age': 25}]
# aa=sorted(alist,key=lambda x:x['age'],reverse=True)
# bb=sorted(alist,key=lambda x:x['age'])
# print(aa)
# print(bb)
# alist.reverse()
# print(alist)

# print([x for x in range(10)])

# list1 = [1,2,3,2]
# list2 = [3,4,5]
# # set1=set(list1)
# set2=set(list2)
# # print(set1)
# print(set1&set2)
# print(set1^set2)
# list3=[]
# # for i in list1:
# #     # print(list1)
# #     if i not in list3:
# #         list3.append(i)
#
# print(list3)
# aa=set(list1)
# print(aa)
# bb=list(aa)
# print(bb)
# print(list(set(list1)))
# print(list(set(list1)))

# list= []
# for i in range(10):
#     list.append(i)
# print(list)
# print(list[1:10])
# print(list[1:7])
# print(list[3:7])
# print(list[9])
# print(list[1:10:2])
# def extendlist(val, list=[]):
#     list.append(val)
#     return list
# list1 = extendlist('a')
# print(list1)
# a = {11,22,33,44,55}
# b = {22,44,55,66,77}
# print(a&b)
# print(a|b)
# print(a-b)
# print(a^b)

# class Hero(object):
#     def info(self):
#         print(self)
#         print('hello world')
# a=Hero()
# a.info()
# print(a)
# # print(id(a))
#
# class Hero(object):
#     """定义了一个英雄类，可以移动和攻击"""
#     # def __init__(self):
#     #     self.name = "泰达米尔"  # 姓名
#     #     self.age = 2600  # 生命值
#     #     self.atk = 450  # 攻击力
#     #     self.armor = 200  # 护甲值
#
#     def __init__(self,name,age,atk,armor):
#         self.name=name
#         self.age=age
#         self.atk=atk
#         self.armor=armor
#
#     def move(self):
#         """实例方法"""
#         print("正在前往事发地点...")
#
#     def attack(self):
#         """实例方法"""
#         self.age=12
#         print("发出了一招强力的普通攻击...")
#
#     def info(self):
#         """在类的实例方法中，通过self获取该对象的属性"""
#         print("英雄 %s 的生命值 :%s" % (self.name, self.age))
#         print("英雄 %s 的攻击力 :%s" % (self.name, self.atk))
#         print("英雄 %s 的护甲值 :%s" % (self.name, self.armor))
#
#     def __str__(self):
#         """
#             这个方法是一个魔法方法 (Magic Method) ，用来显示信息
#             该方法需要 return 一个数据，并且只有self一个参数，当在类的外部 print(对象) 则打印这个数据
#         """
#         return "英雄 <%s> 数据： 生命值 %d, 攻击力 %d, 护甲值 %d" % (self.name, self.age, self.atk, self.armor)
#
#
# a=Hero('aa',2,13,79)
# b=Hero('bb',11,33,555)
# print(a)
# print(Hero.__doc__)
# # a.info()
# # print(id(a))
# # print(id(a.move()))
# # a.move()
# # a.attack()
# print('*'*20)
# b.info()
# print(id(b))
# print(id(b.move()))
import time
#
# class Hero(object):
#
#     # 初始化方法
#     # 创建完对象后会自动被调用
#     def __init__(self, name):
#         print('__init__方法被调用')
#         self.name = name
#
#     # 当对象被删除时，会自动被调用
#     def __del__(self):
#         print("__del__方法被调用")
#         print("%s 被 GM 干掉了..." % self.name)
#
#
# a=Hero('aa')
# # time.sleep(2)
# print('%d被删除1次'%id(a))
# del(a)
# print('--'*10)
# gailun = Hero("盖伦")
# gailun1 = gailun
# gailun2 = gailun
#
# print("%d 被删除1次" % id(gailun))
# del(gailun)
#
# print("%d 被删除1次" % id(gailun1))
# del(gailun1)
#
# print("%d 被删除1次" % id(gailun2))
# del(gailun2)
# 定义一个home类

# def mo_route(alist):
#     for i in range(len(alist)-1):
#         for j in range(len(alist)-1-i):
#             if alist[j]>alist[j+1]:
#                 alist[j],alist[j+1]=alist[j+1],alist[j]

# def select_sort(alist):
#     n=len(alist)
#     for i in range(n-1):
#         min_index=i
#         for j in range(i+1,n):
#             if alist[j]<alist[min_index]:
#                 alist[j],alist[min_index]=alist[min_index],alist[j]

# def insert_sort(alist):
#     for i in range(j,0,-1):
#         if alist[i]<alist[i-1]:
#             alist[i],alist[i - 1]=alist[i-1],alist[i]

# def quict_sort(alist,start,end):
#     if start>=end:
#         return alist
#     mid=alist[start]
#     low=start
#     high=end
#
#
#     while low<high:
#         while low<high and alist[high]>=mid:
#             high-=1
#         alist[low]=alist[high]
#
#         while low<high and alist[low]<mid:
#             low+=1
#         alist[high]=alist[low]
#
#     alist[low]=mid
#     quit_soort(alist,start,low-1)
#     quit_soort(alist,low+1,end)

# def quick_sort(alist, start, end):
#     """快速排序"""
#
#     # 递归的退出条件
#     if start >= end:
#         return
#
#     # 设定起始元素为要寻找位置的基准元素
#     mid = alist[start]
#
#     # low为序列左边的由左向右移动的游标
#     low = start
#
#     # high为序列右边的由右向左移动的游标
#     high = end
#
#     while low < high:
#         # 如果low与high未重合，high指向的元素不比基准元素小，则high向左移动
#         while low < high and alist[high] >= mid:
#             high -= 1
#         # 将high指向的元素放到low的位置上
#         alist[low] = alist[high]
#
#         # 如果low与high未重合，low指向的元素比基准元素小，则low向右移动
#         while low < high and alist[low] < mid:
#             low += 1
#         # 将low指向的元素放到high的位置上
#         alist[high] = alist[low]
#
#     # 退出循环后，low与high重合，此时所指位置为基准元素的正确位置
#     # 将基准元素放到该位置
#     alist[low] = mid
#
#     # 对基准元素左边的子序列进行快速排序
#     quick_sort(alist, start, low-1)
#
#     # 对基准元素右边的子序列进行快速排序
#     quick_sort(alist, low+1, end)
#
# alist = [54,226,93,17,77,31,44,55,20,1]
# # mo_route(alist)
# # select_sort(alist)
# # insert_sort(alist)
# quick_sort(alist,0,len(alist))
# print(alist)

# a=filter(lambda x:x%2,range(10))
# list_a=list(filter(lambda x: x % 2, range(10)))
# str_a=str(filter(lambda x: x % 2, range(10)))
#
# print(a)
# print(list_a)
# print(str_a)
#
#
# b=lambda x, y: x + y
# print(b(1,1))
# print(dir('a'))
# a=lambda x:x+2
# print(a(1))
# a=map(lambda x:x+2,range(10))
# print(list(a))
# reduce(lambda x,y: x*y, range(1,n+1))

# def multipliers():
#     # return [lambda x,i=i:i*x for i in range(4)]
#     return [lambda x : i * x for i in range(4)]
#     # for i in range(4):yield lambda x:i*4
# # print ([m(2) for m in multipliers()])
# print(multipliers())
# print ([m(1) for m in multipliers()])
 ########## 单例类定义 ###########
# class Foo(object):
#
#     __instance = None
#
#     @staticmethod
#     def singleton():
#         if Foo.__instance:
#             return Foo.__instance
#         else:
#             Foo.__instance = Foo()
#             return Foo.__instance
#
# # ########### 获取实例 ###########
# obj = Foo.singleton()

# class A(object):
#     __instance=None
#     def __new__(cls, *args, **kwargs):
#         if cls.__instance is None:
#             cls.__instance=object.__new__(cls)
#             return cls.__instance
#         else:
#             return cls.__instance


# class B(object):
#     __instance=None
#     def __new__(cls, *args, **kwargs):
#         if cls.__instance is None:
#             cls.__instance=object.__new__(cls)
#             return cls.__instance
#         else:
#             return cls.__instance

# def A(fu):
#     def inner():
#         fu()
#     return inner

#
# import time
# def timeit(func):
#     def wrapper():
#         start=time.clock()
#         func()
#         end=time.clock()
#         print('used',end-start)
#     return wrapper
#
# @timeit
# def f():
#     result = 0
#     for i in range(100000):
#
#         result +=i
#         # print(i)
#
#         print(result)
#         # return result
#
#     # print('你好')
# # 添加一个登录验证的功能
# f()



# class person(object):
#     def __init__(self):
#         self.age = 19
#     def age(self):
#         return self.__age
# t= person()

# t.__age = 10print(t.age())
# print(t.age)

# class cat(object):
#     def __init__(self):
#         self.__high=11
#     def high(self):
#         return self.__high
# a=cat()
# print(a.high())


# import re
# reuslt=re.match('aa','aabbb')
# info=reuslt.group()
# print(info)
#
# aa=re.match('..','ahuka')
# print(aa.group())
#
# print(re.match('as','asyuasd').group())
# print(re.search('as','ayuasd').group())
# import re
# aa=re.sub(r'cast','heima','itcast.cn')
# print(aa)

# a='abcdefg'
# print(a.replace('abc','aaa'))

# import re
# result=re.search('aa','ddaadc')
# print(result.group())
# import time
# import multiprocessing
# def a():
#     for i in range(5):
#         print('aa')
#         time.sleep(0.1)
# def b():
#     for i in range(5):
#
#         print('bb')
#         time.sleep(0.1)
#
# if __name__ == '__main__':
#     process1=multiprocessing.Process(target=a)
#     process2=multiprocessing.Process(target=b)
#     process1.start()
#     process2.start()
# import threading
# def a():
#     for i in range(5):
#         print('aa')
#         time.sleep(0.1)
# def b():
#     for i in range(5):
#
#         print('bb')
#         time.sleep(0.1)
# if __name__ == '__main__':
#     thread1=threading.Thread(target=a)
#     thread2=threading.Thread(target=b)
#     thread1.start()
#     thread2.start()

# import os
# from multiprocessing import Process
# import time
# def pro_func(name, age, **kwargs):
#     for i in range(5):
#         print("子进程正在运行中,name=%s, age=%d, pid=%d" %(name, age, os.getpid()))
#         print(kwargs)
#         time.sleep(0.2)
# if __name__ == '__main__':
#  # 创建 Process 对象
#     p = Process(target=pro_func, args=('小明',18), kwargs={'m': 20})
# # 启动进程
#     p.start()
#     time.sleep(1)
# # 1 秒钟之后，立刻结束子进程
#     p.terminate()
#     p.join()

# print(list(map(lambda x:x*x,[y for y in range(3)])))

# import time
# import threading
# aa=0
# lock=threading.Lock()
#
#
# def f1():
#     lock.acquire()
#     global aa
#     for i in range(1000000):
#         aa+=1
#     print(aa)
#     lock.release()
#
# def f2():
#     # lock.acquire()
#     global aa
#     for i in range(1000000):
#
#         aa += 1
#     print(aa)
#     # lock.release()
#
# if __name__ == '__main__':
#     thread1=threading.Thread(target=f1)
#     thread2=threading.Thread(target=f2)
#     thread1.start()
#     thread2.start()

#
# lock=threading.LOck()
# lock.acquire()
# lock.release()
# def  Bubble_sort(alist):
#     for i in range(len(alist)-1):
#         for j  in range(len(alist)-1-i):
#             if alist[j] > alist[j + 1]:
#                     alist[j],alist[j+1]=alist[j+1],alist[j]
# def select_sort(alist):
#     n=len(alist)
#     print(n)
#     # for i in range(n-1):
#     #     min_index=i
#     for j in range(n-1):
#         min_index=j
#         for i in range(1+j,n):
#             if alist[i]<alist[min_index]:
#                 min_index=i
#         alist[min_index],alist[j]=alist[j],alist[min_index]
#
#
#
# def quick_sort(alist,start,end):
#
#     if start>=end:
#         return
#     mid=alist[start]
#     low=start
#     high=end
#
#     while low<high:
#         while low < high and alist[high]>=mid:
#             high-=1
#         alist[low]=alist[high]
#
#         while low<high and alist[low]<mid:
#             low+=1
#         alist[high]=alist[low]
#
#     alist[low]=mid
#     quick_sort(alist,start,low-1)
#     quick_sort(alist,low+1,end)
#
#
# if __name__ == '__main__':
#     alist = [2, 1, 4, 33, 22, 55, 12, 37]
#     quick_sort(alist,0,len(alist)-1)
#     print(alist)
#     # Bubble_sort(alist)
#     select_sort(alist)
#     print(alist)

# select id from students order by id desc limit 0,10
# alter table students change birthday birth datetime not null

# def f1(fn):
#     def inner(*args,**kwargs):
#         print('hello')
#         fn(*args,**kwargs)
#
#         # print('243')
#
#     return inner
#
# @f1
# def count1(a,b):
#     print('1111')
#     result=a+b
#     print(result)

# count1(1,2)

# def login_view(View):
#     def get(self,request):
#         return render(request,'xx.html')
#
#     def post(self,request):
#         username=request.POST.get('username')
#         possword=request.POST.get('possword')
#
#         if not all([username,possword]):
#             return http.httpResponseForbidden('缺少必传参数')
#         if not re.match(r'^[a-zA-Z0-9]{5-20}$',username):
#             return http.httpResponseForbidden("请输入正确")
#
#         user=authenticate(ussername-username,possword=password)
#         if user is None:
#             return render(request,'xx.html',{'count_errmsg':'用户名或密码错误'})
#         login(request,user)
#
#         if remembered !='on':
#             request.session.set_expiry(0)
#
#         else:
#             request.session.set_expiry(None)
#         return redirect(reverse('contents:index'))


# alter table students add birthday datatime
#
# for a in range(1001):
#     for b in range(1001-a):
#         c=1000-a-b
#         # for c in range(1001-a-b):
#         if a+b+c==1000 and a**2+b**2==c**2:
#             print(a,b,c)


# for a in range(0, 1001):
#     for b in range(0, 1001):
#         for c in range(0, 1001):
#             if a**2 + b**2 == c**2 and a+b+c == 1000:
#                 print("a, b, c: %d, %d, %d" % (a, b, c))

# aa={'a':1,'b':3,'c':4,'d':2}
# print(aa.items())
# print(aa.items(),lambda x:x[1])
# print(sorted(aa.items(),key=lambda x:x[1]))
#
# print(sorted(aa.items(),key=lambda x:x[1]))
# from djiango.views.generic import View
# class Register(View):
#     def get(self,request):
#         return render(request,'register.html')
#     def post(self,request):
#         return HttpResponse()
# urlpattern=[url(r'ahsk/'views.RegisterView.as_view())]

# from django.untils.decorators import method_decorator
# class Demoview(View):
#     @method_decorator(my_decorator)
#     def get(self,request):
#         return HttpResponse('ok')
#     @method_decorator(my_decorator)
#     def post(self,request):
#         return Httpresponse('ok')
#     def put(self,request):
#         return HttpResponse('ok')

# def shell_sort(alist):
#     n = len(alist)
#     # 初始步长
#     gap = n // 2
#     while gap > 0:
#         # 按步长进行插入排序
#         for j in range(gap, n):
#             # j = i
#             # 插入排序
#             while j>=gap and alist[j-gap] > alist[j]:
#                 alist[j-gap], alist[j] = alist[j], alist[j-gap]
#                 j -= gap
#         # 得到新的步长
#         gap = gap // 2
#
# alist = [54,26,93,17,77,31,44,55,20]
# shell_sort(alist)
# print(alist)


# a=1
# def f(a):
#     a=2
# print(f(2))
# print(a)
#
# a=[]
# def fun(a):
#     a.append(1)
# fun(a)
# print(a)

# class fang(object):
#     def __init__(self):
#         self.age=12
#         self.high=180
#
# a=fang()
# print(a.age)
print('aaa')